//
//  FMSettingLoginedView.m
//  PsychologyFM
//
//  Created by lanou on 16/1/22.
//  Copyright © 2016年 ZhangLuDu. All rights reserved.
//

#import "FMSettingLoginedView.h"

@implementation FMSettingLoginedView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addHadLoginedView];
    }
    return self;
}

- (void)addHadLoginedView
{
    self.loginScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight - 64)];
    _loginScrollView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight + 150);
    _loginScrollView.showsHorizontalScrollIndicator = NO;
    _loginScrollView.showsVerticalScrollIndicator = NO;
    _loginScrollView.bounces = YES;
    _loginScrollView.alwaysBounceVertical = YES;
    _loginScrollView.alwaysBounceHorizontal = NO;
    //_loginScrollView.backgroundColor = FMCyan;
    [self addSubview:_loginScrollView];

    
    //  登录矩形背景imgview
    _loginImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 30, kScreenWidth - 20, 80)];
    _loginImageView.image = [UIImage imageNamed:@"quitBackground"];
    _loginImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:_loginImageView];
    
    _iconButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _iconButton.frame = CGRectMake(10, 5, 70, 70);
    _iconButton.layer.cornerRadius = 35;
    _iconButton.layer.masksToBounds = YES;
    [_iconButton setImage:[UIImage imageNamed:@"fm50"] forState:(UIControlStateNormal)];
//    [_iconButton addTarget:self action:@selector(iconButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [_loginImageView addSubview:_iconButton];
    
    _loginButton  = [UIButton buttonWithType:UIButtonTypeCustom];
    _loginButton.frame = CGRectMake(_iconButton.right + 10, _iconButton.top + 25, 80, 20);
//    [_loginButton addTarget:self action:@selector(iconButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [_loginButton setTitle:@"立即登陆" forState:(UIControlStateNormal)];
    [_loginButton setTitleColor:FMOrange forState:(UIControlStateNormal)];
    [_loginImageView addSubview:_loginButton];
    
    _changeInformationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _changeInformationButton.frame = CGRectMake(_loginImageView.right - 100 , _loginButton.top, 90, _loginButton.height);
    [_changeInformationButton setTitle:@"修改资料" forState:(UIControlStateNormal)];
    [_changeInformationButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_changeInformationButton setTitleColor:FMGray forState:(UIControlStateNormal)];
    _changeInformationButton.titleLabel.textAlignment = NSTextAlignmentRight;
    [_loginImageView addSubview:_changeInformationButton];
               
    
    //  心情闹钟矩形背景imgview
    UIImageView *alarmImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, _loginImageView.bottom + 15, _loginImageView.width, 60)];
    alarmImageView.image = [UIImage imageNamed:@"quitBackground"];
    alarmImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:alarmImageView];
    //
    _alarmButton = [UIButton buttonWithType:UIButtonTypeCustom];
    // _alarmButton.frame = CGRectMake(0, 0, alarmImageView.width,alarmImageView.height);
    _alarmButton.frame = alarmImageView.bounds;
//    [_alarmButton addTarget:self action:@selector(alarmButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    UIImageView *alarmIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0007_time"]];
    alarmIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_alarmButton addSubview:alarmIconImgView];
    
    UILabel *alarmLabel = [[UILabel alloc]initWithFrame:CGRectMake(alarmIconImgView.right + 5, alarmIconImgView.top + 7.5, 100, 20)];
    alarmLabel.textColor = FMBlack;
    alarmLabel.textAlignment = NSTextAlignmentLeft;
    alarmLabel.text = @"心情闹钟";
    [_alarmButton addSubview:alarmLabel];
    
    [alarmImageView addSubview:_alarmButton];
    
    //  定时矩形背景imgview
    UIImageView *timedImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, alarmImageView.bottom, _loginImageView.width, 60)];
    timedImageView.image = [UIImage imageNamed:@"quitBackground"];
    //timedImageView.backgroundColor = FMYellow;
    timedImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:timedImageView];
    
    _timedButton = [UIButton buttonWithType:UIButtonTypeCustom];
    // _alarmButton.frame = CGRectMake(0, 0, alarmImageView.width,alarmImageView.height);
    _timedButton.frame = CGRectMake(0, 0, alarmImageView.width - 100,alarmImageView.height);;
    
    UIImageView *timedIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"clock"]];
    timedIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_timedButton addSubview:timedIconImgView];
    
    UILabel *timedLabel = [[UILabel alloc]initWithFrame:CGRectMake(timedIconImgView.right + 5, alarmIconImgView.top + 7.5, 100, 20)];
    timedLabel.textColor = FMBlack;
    timedLabel.textAlignment = NSTextAlignmentLeft;
    timedLabel.text = @"定时关闭";
    [_timedButton addSubview:timedLabel];
    
    //  switch
    _timedSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(timedImageView.right - 80, timedLabel.top, 50, timedLabel.height)];
//    [_timedSwitch addTarget:self action:@selector(timedSwitchAction:) forControlEvents:(UIControlEventValueChanged)];
    [timedImageView addSubview:_timedSwitch];
    
    [timedImageView addSubview:_timedButton];
    
    //  清除缓存矩形背景imgview
    UIImageView *clearCacheImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, timedImageView.bottom + 15, _loginImageView.width, 60)];
    clearCacheImageView.image = [UIImage imageNamed:@"quitBackground"];
    clearCacheImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:clearCacheImageView];
    
    _clearCacheButton = [UIButton buttonWithType:UIButtonTypeCustom];
    // _alarmButton.frame = CGRectMake(0, 0, alarmImageView.width,alarmImageView.height);
    _clearCacheButton.frame = alarmImageView.bounds;
//    [_clearCacheButton addTarget:self action:@selector(clearCacheButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    UIImageView *clearIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0007_time"]];
    clearIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_clearCacheButton addSubview:clearIconImgView];
    
    UILabel *clearLabel = [[UILabel alloc]initWithFrame:CGRectMake(alarmIconImgView.right + 5, alarmIconImgView.top + 7.5, 150, 20)];
    clearLabel.textColor = FMBlack;
    clearLabel.textAlignment = NSTextAlignmentLeft;
    clearLabel.text = @"清除图片缓存";
    [_clearCacheButton addSubview:clearLabel];
    
    UILabel *cacheSizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(clearCacheImageView.right - 100, clearLabel.top, 80, 20)];
    cacheSizeLabel.text = @"0.00M";
    cacheSizeLabel.textAlignment = NSTextAlignmentCenter;
    [_clearCacheButton addSubview:cacheSizeLabel];
    
    [clearCacheImageView addSubview:_clearCacheButton];
    
    //  添加绑定QQ和新浪的imageView
    UIImageView *QQImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, clearCacheImageView.bottom + 15, _loginImageView.width, 60)];
    QQImageView.image = [UIImage imageNamed:@"quitBackground"];
    QQImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:QQImageView];
    
    _qqButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _qqButton.frame = CGRectMake(0, 0, alarmImageView.width - 100,alarmImageView.height);;
    
    UIImageView *qqIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0006_qq"]];
    qqIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_qqButton addSubview:qqIconImgView];
    
    UILabel *qqLabel = [[UILabel alloc]initWithFrame:CGRectMake(qqIconImgView.right + 5, qqIconImgView.top + 7.5, 100, 20)];
    qqLabel.textColor = FMBlack;
    qqLabel.textAlignment = NSTextAlignmentLeft;
    qqLabel.text = @"绑定QQ账号";
    [_qqButton addSubview:qqLabel];
    
    //  switch
    _qqSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(QQImageView.right - 80, qqLabel.top, 50, qqLabel.height)];
//    [_qqSwitch addTarget:self action:@selector(qqSwitchAction:) forControlEvents:(UIControlEventValueChanged)];
    [QQImageView addSubview:_qqSwitch];
    
    [QQImageView addSubview:_qqButton];
    
    //  绑定新浪账号的imageView
    
    UIImageView *sinaImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, QQImageView.bottom, _loginImageView.width, 60)];
    sinaImageView.image = [UIImage imageNamed:@"quitBackground"];
    sinaImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:sinaImageView];
    
    _sinaButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _sinaButton.frame = CGRectMake(0, 0, alarmImageView.width - 100,alarmImageView.height);;
    
    UIImageView *sinaIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0005_sina"]];
    sinaIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_sinaButton addSubview:sinaIconImgView];
    
    UILabel *sinaLabel = [[UILabel alloc]initWithFrame:CGRectMake(sinaIconImgView.right + 5, sinaIconImgView.top + 7.5, 150, 20)];
    sinaLabel.textColor = FMBlack;
    sinaLabel.textAlignment = NSTextAlignmentLeft;
    sinaLabel.text = @"绑定新浪账号";
    [_sinaButton addSubview:sinaLabel];
    
    //  switch
    _sinaSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(sinaImageView.right - 80, sinaLabel.top, 50, sinaLabel.height)];
//    [_sinaSwitch addTarget:self action:@selector(sinaSwitchAction:) forControlEvents:(UIControlEventValueChanged)];
    [sinaImageView addSubview:_sinaSwitch];
    
    [sinaImageView addSubview:_sinaButton];
    
    //  分享矩形背景imgview
    UIImageView *shareImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, sinaImageView.bottom + 15, _loginImageView.width, 60)];
    shareImageView.image = [UIImage imageNamed:@"quitBackground"];
    shareImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:shareImageView];
    
    _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    // _alarmButton.frame = CGRectMake(0, 0, alarmImageView.width,alarmImageView.height);
    _shareButton.frame = alarmImageView.bounds;
//    [_shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    UIImageView *shareIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0003_share"]];
    shareIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_shareButton addSubview:shareIconImgView];
    
    UILabel *shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(alarmIconImgView.right + 5, alarmIconImgView.top + 7.5, 150, 20)];
    shareLabel.textColor = FMBlack;
    shareLabel.textAlignment = NSTextAlignmentLeft;
    shareLabel.text = @"分享给好友";
    [_shareButton addSubview:shareLabel];
    
    
    [shareImageView addSubview:_shareButton];
    
    
    //  鼓励矩形背景imgview
    UIImageView *encourageImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, shareImageView.bottom, _loginImageView.width, 60)];
    encourageImageView.image = [UIImage imageNamed:@"quitBackground"];
    encourageImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:encourageImageView];
    
    _encourageButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _encourageButton.frame = alarmImageView.bounds;
//    [_encourageButton addTarget:self action:@selector(encourageButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    UIImageView *encourageIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0002_like"]];
    encourageIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_encourageButton addSubview:encourageIconImgView];
    
    UILabel *encourageLabel = [[UILabel alloc]initWithFrame:CGRectMake(alarmIconImgView.right + 5, encourageIconImgView.top + 7.5, 200, 20)];
    encourageLabel.textColor = FMBlack;
    encourageLabel.textAlignment = NSTextAlignmentLeft;
    encourageLabel.text = @"亲~给个好评鼓励下嘛!";
    [_encourageButton addSubview:encourageLabel];
    
    [encourageImageView addSubview:_encourageButton];
    
    //  反馈矩形背景imgview
    UIImageView *feedBackImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, encourageImageView.bottom, _loginImageView.width, 60)];
    feedBackImageView.image = [UIImage imageNamed:@"quitBackground"];
    feedBackImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:feedBackImageView];
    
    _feedBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _feedBackButton.frame = feedBackImageView.bounds;
//    [_feedBackButton addTarget:self action:@selector(feedBackButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    UIImageView *feedbackIconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"_0000_pen"]];
    feedbackIconImgView.frame = CGRectMake(10, 10, 35, 35);
    [_feedBackButton addSubview:feedbackIconImgView];
    
    UILabel *feedbackLabel = [[UILabel alloc]initWithFrame:CGRectMake(alarmIconImgView.right + 5, feedbackIconImgView.top + 7.5, 100, 20)];
    feedbackLabel.textColor = FMBlack;
    feedbackLabel.textAlignment = NSTextAlignmentLeft;
    feedbackLabel.text = @"反馈意见";
    [_feedBackButton addSubview:feedbackLabel];
    
    [feedBackImageView addSubview:_feedBackButton];
    
    //  退出矩形背景imgview
    UIImageView *quitImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_loginImageView.left, feedBackImageView.bottom + 15, _loginImageView.width, 60)];
    quitImageView.image = [UIImage imageNamed:@"quitBackground"];
    quitImageView.userInteractionEnabled = YES;
    [_loginScrollView addSubview:quitImageView];
    
    _quitButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _quitButton.frame = feedBackImageView.bounds;
//    [_quitButton addTarget:self action:@selector(quitButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [_quitButton setTitle:@"退出" forState:(UIControlStateNormal)];
    [_quitButton setTitleColor:FMBlack forState:(UIControlStateNormal)];
    _quitButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [quitImageView addSubview:_quitButton];
    
    
}




@end
